// Copyright: personal possession of Nguyen Minh Kha
// Class use to manage log in all application/game
// Date time: 08:03PM 07/08/2011(mm/dd/yyyy)
// License: free source
// Version: 1.0
// Writer: Nguyen Minh Kha

#ifndef GAMEFRAMEWORK_LOG_H_
#define GAMEFRAMEWORK_LOG_H_

#include <stdarg.h>
#include <atlstr.h>
#include <strsafe.h>
#include <Windows.h>
#include <d3d9.h>
#include <d3dx9.h>
#include "screen.h"
#include "path.h"

class Log
{
  //
  // Constructor, destructor
  //

public:
  Log(void);
  ~Log(void);

  //
  // Static
  //
public:
  // Write log to file.
  // inputString: [in], don't use unicode character for compatible, please!
  static void Write(LPWSTR inputString,...);
  static void InitStatic();
  // Get rows save in log file
  // numberRow: [in/out], number of row you want to return
  //  change value if return row less than your request
  // return: CString array (length = numberRow or less)
  // Note: use numberRow lower 10.
  static CString* Read(int &numberRow);
  // Switch state of log view
  static void SwitchState();
  // Show error and exit function (copyright microsoft)
  static void ErrorExit(LPTSTR lpszFunction);

  //
  // Static member
  //

  static bool isViewed;
  // manage update status of log
  static bool updateStatus;

  //
  // Method
  // 
public:
  void Init(Screen* screen);
  void Render();
  void Release();
  //
  // Data member
  // 

private:
  // log string array
  CString* logStringArray;
  int numberRow; // log array length

  // Render member
  //
  Screen* screen;
  // private surface of log
  LPDIRECT3DSURFACE9 privateSurface;
  LPDIRECT3DSURFACE9 backBuffer;
  LPDIRECT3DDEVICE9 d3ddev;
  // private suface rect
  RECT rect; 
  RECT textRect;
  LPD3DXFONT d3dxFont;
  int fontSize;
  // color
  D3DCOLOR black;
  D3DCOLOR white;
  DISALLOW_COPY_AND_ASSIGN(Log);
  
};
#endif //GAMEFRAMEWORK_LOG_H_

